package com.humi.partner.front.model;

import java.util.Date;
import java.util.List;

import com.alibaba.druid.util.StringUtils;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.humi.cloud.common.utils.JsonUtil;
import com.humi.cloud.obs.cache.OBSFileCache;
import com.humi.cloud.utils.IocUtil;
import com.humi.partner.common.entity.PartnerApplyRecord.Attachment;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;

/**
 * <pre>
 * <b>Description:</b> 
 * <b>Author:</b> TianJunmin
 * <b>Date:</b> 2019年10月10日
 * </pre>
 */
@Data
@NoArgsConstructor
@ApiModel
@EqualsAndHashCode(callSuper = false)
public class PartnerBasePO extends BaseEntity{

	@ApiModelProperty(value = "  *")
	private static final long serialVersionUID = -7444868361295481149L;
	
	@ApiModelProperty(value = " 企业名称. ")
	private String enterpriseName;
	
	@ApiModelProperty(value = " 申请类型. ")
	private String applyType;
	
	@ApiModelProperty(value = " 申请类型名称. ")
	private String partnerName;
	
	@ApiModelProperty(value = " 公司法人. ")
	private String legalPerson;
	
	@ApiModelProperty(value = " 公司规模. ")
	private String companySize;
	
	@ApiModelProperty(value = " 公司logo. ")
	private String companyLogo;
	
	@ApiModelProperty(value = " 公司官网 ")
	private String companyWeb;
	
	@ApiModelProperty(value = "  公司简介 ")
	private String companyIntroduce;
	
	@JsonIgnore
	@ApiModelProperty(value = "  公司资质的相关文档(JSON数组，obs地址和文件名称)  ")
	private String  companyQualifications;
	
	@ApiModelProperty("附件信息 ")
	private List<Attachment> attachmentList;
	
	public String getCompanyQualifications() {
		return attachmentList!=null?JsonUtil.toJson(attachmentList):null;
	}
	
	public void setCompanyQualifications(String arr) {
		this.companyQualifications=arr;
		if(StringUtils.isEmpty(arr)) {
			return ;
		}
		 List<Attachment> list= JsonUtil.toList(arr, Attachment.class);
		 if(list==null) {
			 return ;
		 }
		 list.forEach(node ->{
			 node.setAddress(IocUtil.getBean(OBSFileCache.class).getFileUrl(node.getAddress()));
		 });
		 attachmentList= list;
	}
	
	@ApiModelProperty(value = "  联系人  ")
	private String contacts;
	
	@ApiModelProperty(value = "  职务 ")
	private String userPost;
	
	@ApiModelProperty(value = "  联系手机  ")
	private String userPhone;
	
	@ApiModelProperty(value = "  联系邮箱  ")
	private String userEmail;
	
	@ApiModelProperty(value = "  联系地址_省  ")
	private String  addrPro;
	
	@ApiModelProperty(value = "   联系地址_市 ")
	private String  addrCity;
	
	@ApiModelProperty(value = "  联系地址_区  ")
	private String  addrArea;
	
	@ApiModelProperty(value = "  详细地址  ")
	private String  addrDetails;
	
	@ApiModelProperty(value = "  申请人ID 【新建修改不填】 ")
	private String  userId;
	
	@ApiModelProperty(value = "  登录账号 【新建修改不填】 ")
	private String  userAccount;
	
	@ApiModelProperty(value = "申请状态(0：审核中；1：审核通过；2：审核驳回重新修改；3：审核驳回不能再提交) ")
	private Integer applyStatus ;
	
	@ApiModelProperty(value = "  审核最后原因  ，【新建修改不填】")
	private String  lastReason;
	
	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
	@ApiModelProperty(value = "最后审核时间",example = "2019-10-11 11:22:00")
	private Date applyTime ;
	
	public void clearDefaultValue() {
		this.createBy=null;
		this.createTime=null;
		this.updateBy=null;
		this.updateTime=null;
		this.valid=null;
		this.version=null;
	}
}
